# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=lzfse
pkgver=1.0
pkgrel=0
pkgdesc="lzfse compression library and command line tool"
url="https://github.com/lzfse/lzfse"
arch="all !s390x" # test fails on s390x
license="BSD-3-Clause"
makedepends="cmake"
subpackages="$pkgname-dev"
source="https://github.com/lzfse/lzfse/archive/refs/tags/lzfse-$pkgver.tar.gz"
builddir="$srcdir/"$pkgname-$pkgname-$pkgver

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
9d7ca44e6d3d2bdf4b82b0eb66c14922369b8b6fe2cf891187a77c6708b8d26c2c1b2ccddec6059e85dbbbb37c497419549f02812b5f34d06238ac246a8cf912  lzfse-1.0.tar.gz
"
